home *** CD-ROM | disk | FTP | other *** search
- /** VLTRequest.vlt
- *
- * DESCRIPTION:
- *
- * Puts up requester(s) and executes a command with the result.
- *
- * CALLING SEQUENCE:
- *
- * VLTRequest.vlt command, hail1, variable1, hail2, variable2, hail3, variable3
- *
- * The commas are used as separators and must be present.
- *
- * The "command" may contain sequences of the form [nxxx]
- * where n is 1, 2, or 3, and x is a combination of letters. The first
- * indicates what type of requester:
- * f file requester
- * g font requester
- * s string requester
- * b boolean requester
- * d no requester, use default as retrieved from variables.
- * Any others may modify the requester type:
- * s "save" requester.
- * d directory requester.
- * Modifiers that don't apply are ignored.
- *
- * The hail1/2/3 strings are used for the requester(s) as hail strings.
- *
- * The variable1/2/3 names are either the names of things that can be
- * extracted from VLT using "extract", or they start with "vlt", in which
- * case an environment variable of that name is created to keep track of
- * of the default. If a [] sequence with the same number is used again,
- * the result previously returned by the requester of that number is
- * substituted.
- *
- * EXAMPLE:
- *
- * ~@VLTRequest.vlt (capture [1fs], Capture File Name:, CAPTUREFILE)
- *
- * What this does is: it will bring up a file requester (with the SAVE flag),
- * with the hailing string "Capture File Name:" and the default that's found
- * by extracting CAPTUREFILE from VLT, and then if the user selects a file,
- * it will substitute it instead of "[1fs]". It then issues the command
- * "capture (filename)" to VLT. If there is no suitable thing to extract
- * from VLT (CAPTUREFILE in the example), then you can use something that
- * starts with "vlt", and it will create an env variable of that name and
- * use that to keep track of the default. You can substitute up to 3
- * requester results in the command by using 1, 2 or 3 as a first character
- * between the []. You can open file requesters (f), font requesters (g),
- * string requester (s) and boolean requesters (b), and the file requester
- * can have options d (directory requester) and s ("save" requester). If you
- * use the same number more than once in command, then whatever the result
- * was for the requester that came up when that number was encountered first
- * will be substituted. Of course, if you pop up more than one requester,
- * you have to supply more commas and hail strings and extract variables.
- * If you don't want to put up a requester but just the current default,
- * you can use "d" as the "requester type".
- *
- * By W.G.J. Langeveld, February 1992.
- *
- **/
- hail. = ""
- envnam. = ""
-
- parse arg cmd "," hail.1 "," envnam.1 "," hail.2 "," envnam.2 "," hail.3 "," envnam.3
-
- cmd = strip(cmd)
- do i = 1 to 3
- hail.i = strip(hail.i)
- envnam.i = strip(envnam.i)
- end
- /*
- * Add libraries if necessary
- */
- if show("l", "rexxarplib.library") = 0 then do
- check = addlib('rexxsupport.library', 0, -30, 0)
- check = addlib('rexxarplib.library', 0, -30, 0)
- end
- /*
- * Determine VLT port and screen name and size
- */
- vltport = address()
- cols = ScreenCols(vltport)
- if cols == -1 then do
- vltscreen = ""
- cols = ScreenCols()
- rows = ScreenRows()
- end
- else do
- vltscreen = vltport
- rows = ScreenRows(vltscreen)
- end
- /*
- * Loop until no more [nxxx] sequences
- */
- k = 0
- rn = 0
- rt = ""
- mf = ""
- filename. = ""
-
- do i = 0
- k = index(cmd, "[", k + 1)
- if k = 0 then leave
- startinsert = k
- /*
- * Find out which requester number, type and flags.
- */
- k = k + 1
- rn = upper(substr(cmd, k, 1))
- k = k + 1
- rt = upper(substr(cmd, k, 1))
-
- flags = ""
- do j = 0
- k = k + 1
- mf = upper(substr(cmd, k, 1))
- if mf = "]" then leave
- else if mf = "S" then flags = flags || "+SAVE"
- else if mf = "G" then flags = flags || "+NOFILES"
- end
- endinsert = k
- /*
- * Get the last stored value
- */
- if substr(envnam.rn, 1, 3) = "VLT" then do
- string = getenv(envnam.rn)
- id = ""
- end
- else do
- "extract "envnam.rn
- id = envnam.rn
- string = VLT.id
- end
- /*
- * If we had this requester number already, we can just use the
- * file name we already had.
- */
- if filename.rn = "" then do
- /*
- * Now decide which kind of requester
- */
- if rt = "D" then do
- filename.rn = string
- end
- else if rt = "F" then do
- filename = string
- dirname = ""
- /*
- * Break up into file and dir
- */
- nf = lastpos("/", filename)
-
- if nf = 0 then do
- nf = lastpos(":", filename)
- if nf ~= 0 then do
- dirname = substr(filename, 1, nf)
- filename = substr(filename, nf + 1)
- end
- end
- else do
- dirname = substr(filename, 1, nf - 1)
- filename = substr(filename, nf + 1)
- end
- /*
- * Find out which entry
- */
- filename.rn = GetFile(80, 50, dirname, filename, hail.rn, vltscreen, flags)
- end
- else if rt = "G" then do
- fontname = string
- filename.rn = GetFont(80, 50, fontname, 8, hail.rn, vltscreen, FIXEDWIDTH, fontstem, 8, 11)
- end
- else if rt = "S" then do
- filename.rn = Request(80, 50, hail.rn, string, " Okay ", "Cancel", vltscreen)
- end
- else if rt = "B" then do
- filename.rn = Request(80, 50, hail.rn,, " Yes ", " No ", vltscreen)
- if filename.rn = "OKAY" then filename.rn = "1"
- else filename.rn = "0"
- end
-
- if filename.rn = "" then exit
- /*
- * Set the file name for next time (only for env vars).
- */
- if id = "" then call setenv(envnam.rn, filename.rn)
- end
- /*
- * substitute the filename in the command
- */
- first = substr(cmd, 1, startinsert - 1)
- last = substr(cmd, endinsert + 1)
- cmd = first || " ("filename.rn") " || last
- end
- /*
- * Execute the command
- */
- ""cmd
-
- exit
-